package messages;


/**
 * AccountEditionFailedMessage
 * 
 * Message sent by the server in reply to an invalid account edition
 * request. The edition will fail if the user has insufficient privilegies
 * (i.e, he is only a regular user trying to mess up with another account)
 * or if the parameters are invalid (user doesn't exist, invalid password, etc).
 */
public class AccountEditionFailedMessage extends Message {

	public enum ErrorCode { UnknownUser, InsufficientPermissions, InvalidParameters }
	
	public AccountEditionFailedMessage(AccountEditMessage originalMessage, ErrorCode errorCode) {
		super();
		
		this.errorCode = errorCode;
		this.originalMessage = originalMessage;
	}
			
	
	public ErrorCode getErrorCode() {
		return this.errorCode;
	}


	public AccountEditMessage getOriginalMessage() {
		return this.originalMessage;
	}
	
	
	@Override
	public String toString() {
		return super.toString() + " " + errorCode + " " + "(" + this.originalMessage + ")";
	}
	

	private ErrorCode errorCode;					// The error code that explains why did the edition fail
	private AccountEditMessage originalMessage;		// The original message sent by the user

	private static final long serialVersionUID = 1L;
}
